-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add gh workflow for raising pr for constants #1832
Conversation
WalkthroughThe pull request introduces enhancements to GitHub Actions workflows related to managing generated constants. A new workflow file, Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1832 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 53 53
Branches 7 7
=========================================
Hits 53 53 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
.github/workflows/raise-pr-for-constants.yml (2)
34-45
: Enhance error handling and file validationThe script should validate file existence and handle potential errors more robustly.
Consider adding:
run: | + if [ ! -f "$SRC_FILE" ]; then + echo "Error: Source file $SRC_FILE not found" + exit 1 + fi + + if [ ! -f "dest-repo/$DEST_PATH" ]; then + echo "Error: Destination file not found" + exit 1 + fi + if cmp -s "$SRC_FILE" "dest-repo/$DEST_PATH"; then🧰 Tools
🪛 actionlint (1.7.4)
34-34: shellcheck reported issue in this script: SC2034:warning:2:1: DEST_REPO appears unused. Verify use (or export if used externally)
(shellcheck)
34-34: workflow command "set-output" was deprecated. use
echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions(deprecated-commands)
34-34: workflow command "set-output" was deprecated. use
echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions(deprecated-commands)
62-67
: Add PR title and body for better contextThe current PR creation lacks descriptive information.
Consider enhancing the PR creation:
if [ -z "$EXISTING_PR" ]; then - gh pr create -f + gh pr create \ + --title "chore: update destination constants" \ + --body "This PR updates the destination constants file. + + - Auto-generated by GitHub Actions + - Source: rudderlabs/rudder-integrations-config + " \ + --label "automated,constants" else echo "PR already exists: $EXISTING_PR" fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (7)
generated/Destinations.dart
is excluded by!**/generated/**
generated/Destinations.java
is excluded by!**/generated/**
generated/Destinations.js
is excluded by!**/generated/**
generated/Destinations.kt
is excluded by!**/generated/**
generated/Destinations.m
is excluded by!**/generated/**
generated/Destinations.swift
is excluded by!**/generated/**
generated/Destinations.ts
is excluded by!**/generated/**
📒 Files selected for processing (8)
.github/workflows/check-generated.yml
(1 hunks).github/workflows/raise-pr-for-constants.yml
(1 hunks)templates/Destinations.dart.template
(1 hunks)templates/Destinations.java.template
(1 hunks)templates/Destinations.kt.template
(1 hunks)templates/Destinations.m.template
(1 hunks)templates/Destinations.swift.template
(1 hunks)templates/Destinations.ts.template
(1 hunks)
✅ Files skipped from review due to trivial changes (6)
- templates/Destinations.ts.template
- templates/Destinations.dart.template
- templates/Destinations.swift.template
- templates/Destinations.kt.template
- templates/Destinations.m.template
- templates/Destinations.java.template
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/raise-pr-for-constants.yml
34-34: shellcheck reported issue in this script: SC2034:warning:2:1: DEST_REPO appears unused. Verify use (or export if used externally)
(shellcheck)
34-34: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
(deprecated-commands)
34-34: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
(deprecated-commands)
48-48: if: condition "${{ needs.check_changes.outputs.pr_required }} == 'true'" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
🔇 Additional comments (2)
.github/workflows/check-generated.yml (1)
35-36
: Great addition to improve developer feedback!
The addition of git diff output will help developers quickly understand what changes need to be committed, improving the workflow's usability.
.github/workflows/raise-pr-for-constants.yml (1)
24-24
: Verify repository access permissions
Ensure that the PAT has the necessary permissions to access both repositories and that the destination repository allows workflow-created PRs.
✅ Verification successful
Let me gather more information about the workflow configuration and permissions.
Repository access is properly configured with necessary permissions
The workflow is correctly set up with:
- Uses PAT secret for authentication (
${{ secrets.PAT }}
) - Has proper git configuration for commits
- Implements PR creation using GitHub CLI
- Target repository (
rudderlabs/rudder-sdk-js
) is public and active - Includes proper error handling for branch operations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if the destination repository exists and is accessible
gh repo view rudderlabs/rudder-sdk-js --json name,visibility,isArchived
# Check if there are any existing PRs from this workflow
gh pr list -R rudderlabs/rudder-sdk-js \
--search "author:app/github-actions in:title update destination constants" \
--json number,title,state
Length of output: 284
Script:
#!/bin/bash
# Check the workflow configuration for permissions and token usage
cat .github/workflows/raise-pr-for-constants.yml
# Check if there are any other workflows that interact with the same repository
rg -l "rudderlabs/rudder-sdk-js" .github/workflows/
Length of output: 2420
5ba6d5c
to
f2219b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/raise-pr-for-constants.yml (1)
12-14
: Consider using a dynamic branch name.The hardcoded branch name could cause conflicts if multiple PRs need to be created simultaneously. Consider including a timestamp or unique identifier.
env: - BRANCH_NAME: chore/gh-update-destinations-ts + BRANCH_NAME: chore/gh-update-destinations-ts-${{ github.run_id }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (6)
generated/Destinations.dart
is excluded by!**/generated/**
generated/Destinations.java
is excluded by!**/generated/**
generated/Destinations.kt
is excluded by!**/generated/**
generated/Destinations.m
is excluded by!**/generated/**
generated/Destinations.swift
is excluded by!**/generated/**
generated/Destinations.ts
is excluded by!**/generated/**
📒 Files selected for processing (8)
.github/workflows/check-generated.yml
(1 hunks).github/workflows/raise-pr-for-constants.yml
(1 hunks)templates/Destinations.dart.template
(1 hunks)templates/Destinations.java.template
(1 hunks)templates/Destinations.kt.template
(1 hunks)templates/Destinations.m.template
(1 hunks)templates/Destinations.swift.template
(1 hunks)templates/Destinations.ts.template
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- templates/Destinations.m.template
🚧 Files skipped from review as they are similar to previous changes (6)
- templates/Destinations.ts.template
- templates/Destinations.java.template
- .github/workflows/check-generated.yml
- templates/Destinations.swift.template
- templates/Destinations.dart.template
- templates/Destinations.kt.template
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/raise-pr-for-constants.yml
39-39: shellcheck reported issue in this script: SC2034:warning:2:1: DEST_REPO appears unused. Verify use (or export if used externally)
(shellcheck)
39-39: shellcheck reported issue in this script: SC2086:info:7:31: Double quote to prevent globbing and word splitting
(shellcheck)
39-39: shellcheck reported issue in this script: SC2086:info:10:30: Double quote to prevent globbing and word splitting
(shellcheck)
🪛 yamllint (1.35.1)
.github/workflows/raise-pr-for-constants.yml
[error] 36-36: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/raise-pr-for-constants.yml (1)
1-11
: LGTM! Well-configured workflow triggers and permissions.
The workflow is correctly configured to trigger on pushes to the develop branch, and the required permissions are explicitly declared following security best practices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All coderabbit suggestions are relevant and should be considered to make changes.
Work flow looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
.github/workflows/raise-pr-for-constants.yml (1)
56-61
: Enhance commit operation with better error handling and message.The commit operation needs better error handling and a more descriptive commit message.
cd dest-repo -cp "../generated/Destinations.ts" "packages/analytics-js-common/src/constants/integrations/Destinations.ts" +cp "../${{ env.SRC_FILE }}" "${{ env.DEST_PATH }}" || { + echo "Error: Failed to copy file" + exit 1 +} git add packages/analytics-js-common/src/constants/integrations/Destinations.ts -git commit -m "chore: update destinations.ts" +git commit -m "chore: update destination constants + +Update Destinations.ts with latest constants from source repository" git push origin ${{ env.BRANCH_NAME }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/raise-pr-for-constants.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/raise-pr-for-constants.yml
41-41: shellcheck reported issue in this script: SC2086:info:3:31: Double quote to prevent globbing and word splitting
(shellcheck)
41-41: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting
(shellcheck)
🔇 Additional comments (4)
.github/workflows/raise-pr-for-constants.yml (4)
1-11
: LGTM! Well-structured workflow configuration.
The workflow configuration follows best practices with:
- Clear workflow name
- Appropriate trigger on develop branch
- Explicit permissions declaration
12-16
: LGTM! Well-defined environment variables.
Environment variables are appropriately defined at the workflow level with clear naming conventions.
69-71
: 🛠️ Refactor suggestion
Enhance PR creation with better title and description.
The current PR creation is too basic. Consider adding a more descriptive title and body.
-gh pr create -f
+gh pr create \
+ --title "chore: update destination constants [automated]" \
+ --body "## Description
+
+This PR updates the destination constants file with the latest changes.
+
+## Changes
+- Updated \`Destinations.ts\` with latest constants from source repository
+
+This PR was automatically generated by GitHub Actions." \
+ --label "automated"
Likely invalid or redundant comment.
31-31
: 🛠️ Refactor suggestion
Enhance security of git clone operation.
Consider using the actions/checkout
action instead of direct git clone for better security and maintainability.
-git clone https://github.com/${DEST_REPO}.git dest-repo || exit 1
+uses: actions/checkout@v4
+with:
+ repository: ${DEST_REPO}
+ path: dest-repo
+ token: ${{ secrets.GITHUB_TOKEN }}
Likely invalid or redundant comment.
c82ef88
to
c9f47b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
.github/workflows/raise-pr-for-constants.yml (2)
56-61
: Improve file operations and commit messageConsider these improvements:
- Use environment variables consistently
- Add more descriptive commit message
-cp "../generated/Destinations.ts" "packages/analytics-js-common/src/constants/integrations/Destinations.ts" -git add packages/analytics-js-common/src/constants/integrations/Destinations.ts -git commit -m "chore: update destinations.ts" +cp "../${SRC_FILE}" "${DEST_PATH}" +git add "${DEST_PATH}" +git commit -m "chore: update destination constants [automated] + +This commit updates the destination constants file with the latest changes from the source repository."
70-78
: Enhance PR creation with better metadataConsider these improvements:
- Remove trailing spaces
- Add more context to PR description
- Add additional useful labels
gh pr create \ --title "chore: update destination constants" \ --body "This PR updates the destination constants file. **Changes:** - Updated \`Destinations.ts\` with latest constants - + This PR was automatically generated by GitHub Actions." \ - --label "automated,dependencies" + --label "automated,dependencies,no-changelog-needed" \ + --assignee "@me"🧰 Tools
🪛 yamllint (1.35.1)
[error] 76-76: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/raise-pr-for-constants.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/raise-pr-for-constants.yml
41-41: shellcheck reported issue in this script: SC2086:info:3:31: Double quote to prevent globbing and word splitting
(shellcheck)
41-41: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting
(shellcheck)
🪛 yamllint (1.35.1)
.github/workflows/raise-pr-for-constants.yml
[error] 76-76: trailing spaces
(trailing-spaces)
🔇 Additional comments (4)
.github/workflows/raise-pr-for-constants.yml (4)
1-11
: LGTM! Well-configured workflow trigger and permissions
The workflow trigger and permissions are properly configured:
- Triggers on push to develop branch
- Explicit permissions for contents and pull-requests write access
12-16
: LGTM! Well-structured environment variables
Good practice using environment variables for reusable values. The paths and branch naming are well-structured.
31-31
:
Security: Avoid exposing credentials in git clone URL
Replace the current git clone command with a more secure approach:
-git clone https://github.com/${DEST_REPO}.git dest-repo || exit 1
+git clone https://github.com/${DEST_REPO}.git dest-repo
+cd dest-repo
+git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
42-48
: 🛠️ Refactor suggestion
Add proper quoting and error handling to file comparison
Add proper quoting to prevent issues with special characters:
-if cmp -s "${{ env.SRC_FILE }}" "dest-repo/${{ env.DEST_PATH }}"; then
+if cmp -s "${SRC_FILE}" "dest-repo/${DEST_PATH}"; then
echo "No changes detected." > "result.txt"
echo "pr_required=false" >> $GITHUB_OUTPUT
else
echo "Changes detected." > "result.txt"
echo "pr_required=true" >> $GITHUB_OUTPUT
fi
c9f47b8
to
993b522
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
.github/workflows/raise-pr-for-constants.yml (2)
69-77
: Enhance PR creation with better metadata and error handlingThe PR creation needs improvements:
- More descriptive title and body
- Better error handling for file operations
- More specific labels
- gh pr create \ - --title "fix: update destination constants" \ - --body "This PR updates the destination constants file. - - **Changes:** - - Updated \`Destinations.ts\` with latest constants - - This PR was automatically generated by GitHub Actions." \ - --label "automated,dependencies" + { + echo "Changes in destination constants:" + diff -u "dest-repo/${{ env.DEST_PATH }}" "${{ env.SRC_FILE }}" || true + } > pr_diff.txt + + gh pr create \ + --title "fix: update destination constants [$(date +%Y-%m-%d)]" \ + --body "This PR updates the destination constants with the latest changes. + + **Changes:** + - Updated \`Destinations.ts\` with latest constants from \`develop\` branch + + <details> + <summary>Detailed Changes</summary> + + \`\`\`diff + $(cat pr_diff.txt) + \`\`\` + </details> + + This PR was automatically generated by GitHub Actions. + + Related to: #${GITHUB_EVENT_NUMBER:-N/A}" \ + --label "automated,dependencies,constants-update"🧰 Tools
🪛 yamllint (1.35.1)
[error] 75-75: trailing spaces
(trailing-spaces)
75-75
: Remove trailing whitespaceThere is trailing whitespace on this line that should be removed.
- +🧰 Tools
🪛 yamllint (1.35.1)
[error] 75-75: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
.github/workflows/check-generated.yml
(1 hunks).github/workflows/raise-pr-for-constants.yml
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/check-generated.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/raise-pr-for-constants.yml
40-40: shellcheck reported issue in this script: SC2086:info:3:31: Double quote to prevent globbing and word splitting
(shellcheck)
40-40: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting
(shellcheck)
🪛 yamllint (1.35.1)
.github/workflows/raise-pr-for-constants.yml
[error] 75-75: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/raise-pr-for-constants.yml (1)
31-35
:
Enhance security and Git configuration
The Git clone and configuration steps need security improvements:
- Use HTTPS URL without embedding token
- Add error handling for Git operations
- Set Git configuration before clone
- git clone https://github.com/${DEST_REPO}.git dest-repo || exit 1
- cd dest-repo
- git config --global user.name "GitHub Actions"
- git config --global user.email "[email protected]"
- git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
+ git config --global user.name "GitHub Actions"
+ git config --global user.email "[email protected]"
+ git clone https://github.com/${DEST_REPO}.git dest-repo || {
+ echo "Failed to clone repository"
+ exit 1
+ }
+ cd dest-repo || exit 1
+ git remote set-url origin "https://${{ secrets.GITHUB_TOKEN }}@github.com/${DEST_REPO}.git"
Likely invalid or redundant comment.
What are the changes introduced in this PR?
raise PR when constant files are changed
What is the related Linear task?
Resolves INT-2930
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new checks got introduced or modified in test suites. Please explain the changes.
N/A
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
I have executed schemaGenerator tests and updated schema if needed
Are sensitive fields marked as secret in definition config?
My test cases and placeholders use only masked/sample values for sensitive fields
Is the PR limited to 10 file changes & one task?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.
Summary by CodeRabbit